#include <iostream>
#include <cstdio>
using namespace std;

int getEven(int n)
{
    if (n <= 2)
        return -1;
    if (n % 4 == 0)
        return 3;
    if (n % 2 == 0)
        return 4;
    if (n % 2 == 1)
        return 2;
    return -1;
}
int main() {
    int n;
    cin >> n;

    cout << getEven(n) << endl;
    return 0;
}